package logic

import (
	"context"
	"renting-demo/common"
	"renting-demo/model/mysql"
	"renting-demo/order_srv/internal/svc"
	"renting-demo/order_srv/order"
	"strconv"

	"github.com/zeromicro/go-zero/core/logx"
)

type PayLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPayLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PayLogic {
	return &PayLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// todo:支付订单
func (l *PayLogic) Pay(in *order.PayOrderReq) (*order.Response, error) {

	o := mysql.GetOrder(strconv.Itoa(int(in.Orderid)))
	url := common.Pay(o.OrderSn, strconv.Itoa(int(o.TotalPrice)))
	return &order.Response{
		Status: url,
	}, nil
}
